<template>
	<view class="order">
		<!-- 列表 -->
		<view class="listBox">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="order_tit">
					{{item.time}}
				</view>
				<view class="list_l">
					<image :src="baseUrl+item.image" mode=""></image>
					<view class="list_l_r">
						<view class="name" style="font-size: 26rpx;">{{item.name}}</view>
						<view class="name">
							<view class="" style="color: #F06E56;">
								￥{{item.phone}}
							</view>
							<view class="num">
								x{{item.number}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<!-- 提示栏 -->
		<view style="width: 100%; text-align: center; font-size: 28rpx; margin-top: 30rpx;">{{isText}}</view>

	</view>
	</view>
</template>

<script>
	import config from '@/common/config/config';
	export default {
		data() {
			return {
				baseUrl: config.baseurl,
				tabCurrent: 0,
				page: 1,
				list: [],
				isText: '',
				backup: '',
				last_page: 1
			};
		},
		onLoad() {

		},
		onShow() {
			this.list = []
			this.page = 1
			this.isText = ''
			this.getList()
		},
		methods: {
			// 获取员工列表
			getList() {
				let that = this

				that.list = [{
						name: '鸿著·鸿运 (53”雪莲大曲酱香)/4箱/24瓶',
						phone: '9576.00',
						time: 'HY202303272312345',
						image: "static/index/orderIcon.png",
						number: '2'
					},
					{
						name: '鸿著·鸿运 (53”雪莲大曲酱香)/4箱/24瓶',
						phone: '9576.00',
						time: 'HY202303272312345',
						image: "static/index/orderIcon.png",
						number: '1',

					}
				]
				// that.$api.listByMember({
				// 	page: that.page,
				// }).then(res => {
				// 	res.data.rows.length == 0 ? that.isText = '暂无数据' : that.isText = ''
				// 	that.list = that.list.concat(res.data.rows)
				// 	that.last_page = Math.ceil(res.data.rows.length / res.data.total)
				// 	this.backup = res.data.backup
				// 	console.log(res.data.rows, 'that.list')
				// })
			},
			// 点击提货
			pickUpGoods(el) {
				let that = this
				uni.showModal({
					title: "确定是否提货",
					success: function(res) {
						if (res.confirm) {
							that.$api.orderTh({
								order_number: el.order_number,
							}).then(res => {
								console.log(res)
								that.goDetails(el)
							})
						} else {
							console.log('用户点击取消');
						}
					}
				});

			},
			// 点击回购
			buyBack(el) {
				let that = this
				uni.showModal({
					title: "确定是否回购",
					success: function(res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.$api.orderHg({
								order_number: el.order_number,
							}).then(res => {
								console.log(res)
								that.goDetails(el)
							})
						} else {
							console.log('用户点击取消');
						}
					}
				});
			},
			// 点击拨号
			callPhone(phoneNumber) {
				uni.makePhoneCall({
					phoneNumber,
				});
			},
			goMoney() {
				uni.navigateTo({
					url: '/pages/my/withdrawal/withdrawal'
				})
			},
			// 跳转到详情页面
			goDetails(el) {
				let res = {
					order_number: el.order_number,
					goods_img: el.goods_img,
					goods_name: el.goods_name
				}
				uni.navigateTo({
					url: '/pages/order/details/details?res=' + JSON.stringify(res)
				})
			}
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
				that.getList()
			}
		}

	}
</script>

<style lang="less">
	page {
		background-color: #f9f9f9;
	}

	.u-tab-bar {
		display: none !important;
	}

	.order {
		width: 100vw;

		.listBox {
			width: 95%;
			margin: 30rpx auto;

			.list {
				width: 100%;
				height: auto;
				padding: 20rpx;
				border-radius: 20rpx;
				background-color: #fff;
				margin: 20rpx auto;

				.order_tit {
					height: 58rpx;
					line-height: 45rpx;
					color: #000;
					border-bottom: 2rpx solid gainsboro;
					font-size: 30rpx;
				}

				.list_l {
					margin: 14rpx auto;
					width: 100%;
					color: #252525;
					display: flex;
					align-items: center;

					image {
						width: 84rpx;
						height: 84rpx;
					}

					.list_l_r {
						font-size: 28rpx;
						font-weight: 400;
						margin-left: 20rpx;
						width: 86%;

						.name {
							height: 50rpx;
							line-height: 50rpx;
							display: flex;
							color: #000;
							justify-content: space-between;
							align-items: center;

							.num {
								border-radius: 6rpx;
								width: 34rpx;
								margin: 8rpx;
								height: 34rpx;
								border: 2rpx solid gainsboro;
								color: #BABABA;
								font-size: 24rpx;
								display: flex;
								align-items: center;
								justify-content: center;
							}
						}
					}
				}
			}
		}
	}
</style>